package com.gaojunxiang.service.impl;
import com.gaojunxiang.dao.UserDao;
import com.gaojunxiang.domain.User;
import com.gaojunxiang.service.UserServiceInter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserServiceInter {
    //注入dao
    @Autowired(required = false)
   private UserDao userDao;

    @Override
    public boolean save(User user) {
        return userDao.save(user);
    }

    @Override
    public boolean delete(Integer uid) {
        return userDao.delete(uid);
    }

    @Override
    public boolean update(User user) {
        return userDao.update(user);
    }

    @Override
    public  PageInfo<User> findAllUser(int currentPage,int pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<User> allUser = userDao.findAllUser();
        PageInfo<User> userPageInfo = new PageInfo<>(allUser);
        return userPageInfo;
    }

    @Override
    public User findById(Integer id) {
       return userDao.findById(id);
    }

}
